package com.dai.zhenfujin.adapter;

import android.content.Context;
import android.content.Intent;

import com.bumptech.glide.Glide;
import com.dai.zhenfujin.BaseAdapter.BaseRecycleAdapter;
import com.dai.zhenfujin.BaseAdapter.BaseViewHolder;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.bean.FollowBean;
import com.dai.zhenfujin.db.Constant;
import com.dai.zhenfujin.message.ChatActivity;
import com.dai.zhenfujin.utils.SPUtils;
import com.dai.zhenfujin.visitingcard.app.PersonalDetailsActivity;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class AttentionDetailAdapter extends BaseRecycleAdapter<FollowBean.FollowListBean> {
    private List<FollowBean.FollowListBean> dataList;
    private Context mContext;
    private BaseViewHolder.onItemCommonClickListener commonClickListener;


    public AttentionDetailAdapter(Context context, List<FollowBean.FollowListBean> dataList, BaseViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, com.dai.zhenfujin.R.layout.itme_attention_list);
        this.dataList = dataList;
        this.commonClickListener = commonClickListener;
        mContext = context;
    }

    @Override
    public void bindData(BaseViewHolder holder, FollowBean.FollowListBean data) {
        holder.setText(com.dai.zhenfujin.R.id.pp_adapter_name, data.user_name);
        holder.setText(com.dai.zhenfujin.R.id.pp_adapter_bloc,"公司:" + data.user_company);
        holder.setText(com.dai.zhenfujin.R.id.pp_adapter_position, data.user_duties);
        holder.setText(com.dai.zhenfujin.R.id.item_word_type,"主业:" +  data.user_job);
        Glide.with(mContext).load(data.user_logo).into((CircleImageView) holder.getView(R.id.cv_img));
        holder.getView(R.id.pp_adapter_ll).setOnClickListener(v -> {
            //头像
            SPUtils.saveConversionHeadPhoto(mContext,data.user_mobile,data.user_logo);
            //昵称
            SPUtils.saveConversionNickName(mContext,data.user_mobile,data.user_name);
            //职业
            SPUtils.saveConversionUserDuties(mContext,data.user_mobile,data.user_duties);

            Intent intent = new Intent(mContext, ChatActivity.class);
            intent.putExtra(Constant.EXTRA_USER_ID, data.user_mobile);
            mContext.startActivity(intent);
        });
        holder.getView(R.id.cv_img).setOnClickListener(v -> { //TA的详情
            Intent intent = new Intent(mContext,PersonalDetailsActivity.class);
            intent.putExtra("user_id", data.user_mobile);
            intent.putExtra("type", 1);
            mContext.startActivity(intent);
        });
    }
}
